<%@ page import="driver.dao.SchoolDao" %>
<%@ page import="driver.entity.School" %>
<%@ page import="java.util.ArrayList" %><%--
  Created by IntelliJ IDEA.
  User: LSK
  Date: 2019/10/23
  Time: 23:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>

<head>
    <title>西安学车管家</title>

    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="img/bitbug_favicon.ico">
    <base target="_blank" />
    <link rel="stylesheet" href="bootstrap/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="layui/layui/css/layui.css">
    <title>Title</title>
</head>
<style>
    body {
        margin: 0;
        padding: 0;
        background-color: rgb(241, 241, 241);
    }

    #search {
        background: #ffffff;
        box-shadow: 2px 0px 15px 1px rgb(231, 231, 231);
    }

    #search li {
        border-bottom: 1px solid rgb(255, 255, 255);
    }

    #search li:hover {
        border-bottom: 1px solid #5FB878;
    }

    #search .navbar-brand:hover,
    #search li a:hover {
        color: #5FB878;
    }

    .container,
    .container-fluid {
        padding: 20px;
        background: #fff;
    }

    .layui-form-label {
        font-size: 14px;
        width: 150px;
    }

    #layuiButton{
        opacity: 0.2;
        margin-left: 100px;
        transition: all 0.8s ease-out;
    }
</style>

<body>
    <!--导航条-->
    <nav class="navbar navbar-default " id="search">
        <div class="container">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                    data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a target='_blank' class="navbar-brand" href="index.jsp" data-toggle="tooltip" data-placement="bottom"
                    title="返 回 首 页">
                    <img src="asset/logoBig.png" style="width: 100px;height:38px;margin-top: -7px" alt="">
                </a>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav">
                    <li><a target='_blank' href="showusers.jsp?page=0">查看所有学员基本信息 <span class="sr-only"></span></a></li>
                    <li><a target='_blank' href="adduser.jsp">批量导入学员基本信息</a></li>
                    <li><a target='_blank' href="payfor.jsp?page=0">处理学员理赔信息</a></li>
                    <li><a target='_blank' href="showschools.jsp">驾校信息查看</a></li>
                </ul>
                <!--<ul class="nav navbar-nav navbar-right">
                    <li><a target='_blank'  href="#">当前登录用户:管理员</a></li>
                    <li class="dropdown">
                        <a target='_blank'  href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
                            aria-expanded="false">用户操作 <span class="caret"></span></a>
                        <ul class="dropdown-menu">
                            <li><a target='_blank'  href="#">退出登录</a></li>
                            <li><a target='_blank'  href="#">退出登录</a></li>
                            <li><a target='_blank'  href="#">退出登录</a></li>
                        </ul>
                    </li>
                </ul>-->
            </div><!-- /.navbar-collapse -->
        </div><!-- /.container-fluid -->
    </nav>


    <%
    ArrayList<School> schools = new SchoolDao().select_school();
    pageContext.setAttribute("schools",schools);
%>
    <!-- 内容主体 -->
    <div class="container">
        <div class="layui-card">
            <div class="layui-card-header">
                <h2>驾校信息展示</h2>
            </div>
            <div class="layui-card-body">
                <table class="table">
                    <thead>
                        <tr>
                            <th>编号</th>
                            <th>驾校负责人姓名</th>
                            <th>驾校负责人电话</th>
                            <th>驾校负责人身份证号码</th>
                            <th>驾校名称</th>
                            <th>密码</th>
                            <th>修改</th>
                        </tr>
                    </thead>
                    <tbody>
                        <%
    for (int i = 0; i < schools.size(); i++) {
        pageContext.setAttribute("i",i);
        %>
                        <tr>
                            <td>${schools.get(i).id}</td>
                            <td>${schools.get(i).name}</td>
                            <td>${schools.get(i).phonenum}</td>
                            <td>${schools.get(i).idcard}</td>
                            <td>${schools.get(i).schoolname}</td>
                            <td>${schools.get(i).pass}</td>
                        </tr>
                    </tbody>
                    <%
    }%>

                </table>
                <hr class="layui-bg-green">
                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                    <legend>
                        <h3>添加模块</h3>
                    </legend>
                </fieldset>

                <form class="layui-form" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">姓名</label>
                            <div class="layui-input-inline">
                                <input type="text" name="name" id="name" lay-verify="name" autocomplete="off"
                                    class="layui-input" placeholder="输入姓名">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label"> 负责人手机号码</label>
                            <div class="layui-input-inline">
                                <input type="tel" name="phonenum" id="phonenum" lay-verify="required|phone"
                                    autocomplete="off" class="layui-input" placeholder="输入负责人手机号码">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label"> 负责人身份证号码</label>
                            <div class="layui-input-inline">
                                <input type="text" name="idnum" id="idnum" lay-verify="required|number"
                                    autocomplete="off" class="layui-input" placeholder="输入身份证号码">
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">驾校名称</label>
                            <div class="layui-input-inline">
                                <input type="text" name="schoolnum" id="schoolnum" placeholder="输入驾校名称"
                                    autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label"> 驾校登录密码</label>
                            <div class="layui-input-inline">
                                <input type="password" name="pass" id="pass" lay-verify="pass" autocomplete="off"
                                    class="layui-input layui-form-mid layui-word-aux" placeholder="输入登录密码">
                            </div>
                        </div>
                        <div class="layui-inline" id="layuiButton"> <button type="button" onclick="fun()" class="btn btn-success"
                                style="margin-left: 20px;margin-top: -6px;">提交按钮</button></div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <script src="bootstrap/dist/js/jquery-3.4.1.min.js"></script>
    <script src="bootstrap/dist/js/bootstrap.min.js"></script>
    <script src="bootstrap/dist/js/layui/layui.all.js"></script>
    <!--此页面展示所有学校的信息-->
    <script>
        /* 鼠标特效 */
        var a_idx = 0;
        jQuery(document).ready(function ($) {
            $("body").click(function (e) {
                var a = ["富强", "民主", "文明", "和谐", "自由", "平等", "公正", "法治", "爱国", "敬业", "诚信", "友善"];
                var $i = $("<span/>").text(a[a_idx]);
                a_idx = (a_idx + 1) % a.length;
                var x = e.pageX,
                    y = e.pageY;
                $i.css({
                    "z-index": 9999999999999999999999999999999999999999,
                    "top": y - 20,
                    "left": x,
                    "position": "absolute",
                    "font-weight": "bold",
                    "color": "#ff6651"
                });
                $("body").append($i);
                $i.animate({
                        "top": y - 180,
                        "opacity": 0
                    },
                    1500,
                    function () {
                        $i.remove();
                    });
            });
        });
        //alert("用户名不存在，请联系管理员");
    </script>
    <script src="Lskjs/lskjs.js" charset="utf-8">

    </script>
    <script>
        function fun() {
            //使用$.ajax()发送异步请求
            if ($("#name").val().length === 0 ||
                $("#phonenum").val().length === 0 ||
                $("#idnum").val().length === 0 ||
                $("#schoolnum").val().length === 0 ||
                $("#pass").val().length === 0) {
                // myalert("以上信息均不能为空，请检测后重新提交");
                layui.use('layer', function () {
                    var layer = layui.layer;

                    layer.msg("以上信息均不能为空，请检测后重新提交", {
                        time: 20000, //20s后自动关闭
                        btn: ['确认']
                    });
                    $('.layui-layer-msg').css('backgroundColor', 'rgba(0,150,136,0.5)');

                });
            } else {
                $.ajax({
                    url: "${pageContext.request.contextPath}/doSchool", // 请求路径
                    type: "POST", //请求方式
                    //data: "username=jack&age=23",//请求参数
                    data: {
                        "name": $("#name").val(),
                        "phonenum": $("#phonenum").val(),
                        "idnum": $("#idnum").val(),
                        "schoolnum": $("#schoolnum").val(),
                        "pass": $("#pass").val()
                    },
                    success: function (data) {
                        //myalter(data);
                        layui.use('layer', function () {
                            var layer = layui.layer;

                            layer.msg(data, {
                                time: 20000, //20s后自动关闭
                                btn: ['确认']
                            });
                            $('.layui-layer-msg').css('backgroundColor', 'rgba(0,150,136,0.5)');

                        });
                        window.location.reload(); //刷新页面
                    }, //响应成功后的回调函数
                    error: function () {
                        //myalter("出错啦...")
                        layui.use('layer', function () {
                            var layer = layui.layer;

                            layer.msg("出错啦", {
                                time: 20000, //20s后自动关闭
                                btn: ['确认']
                            });
                            $('.layui-layer-msg').css('backgroundColor', 'rgba(0,150,136,0.5)');

                        });
                    }, //表示如果请求响应出现错误，会执行的回调函数
                    dataType: "text" //设置接受到的响应数据的格式
                });
            }
        }

        $(function(){
            $('#layuiButton').css({"opacity":"1","transform":"translateX(-100px)"})
        })
    </script>
</body>

</html>